//package com.platform.mall.security.core.userdetails.member;
//
//import com.platform.mall.common.enums.AuthenticationIdentityEnum;
//import com.platform.mall.common.result.ResultCode;
//import com.platform.mall.model.dto.MemberAuthInfoDTO;
//import com.platform.mall.service.MemberUserService;
//import lombok.RequiredArgsConstructor;
//import org.springframework.security.authentication.AccountExpiredException;
//import org.springframework.security.authentication.DisabledException;
//import org.springframework.security.authentication.LockedException;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.stereotype.Service;
//
///**
// * 商城会员用户认证服务
// *
// * @author <a href="mailto:xianrui0365@163.com">haoxr</a>
// */
//@Service("memberUserDetailsService")
//@RequiredArgsConstructor
//public class UserMemberDetailsServiceImpl implements UserDetailsService {
//
//    private final MemberUserService memberUserService;
//
//    @Override
//    public UserDetails loadUserByUsername(String username) {
//        return null;
//    }
//
//
//    /**
//     * 手机号码认证方式
//     *
//     * @param mobile
//     * @return
//     */
//    public UserDetails loadUserByMobile(String mobile) {
//        MemberUserDetails userDetails = null;
//        MemberAuthInfoDTO member = memberUserService.loadUserByMobile(mobile);
//        if (null != member) {
//            userDetails = new MemberUserDetails(member);
//            userDetails.setAuthenticationIdentity(AuthenticationIdentityEnum.MOBILE.getValue());   // 认证身份标识:mobile
//        }
//        if (userDetails == null) {
//            throw new UsernameNotFoundException(ResultCode.USER_NOT_EXIST.getMsg());
//        } else if (!userDetails.isEnabled()) {
//            throw new DisabledException("该账户已被禁用!");
//        } else if (!userDetails.isAccountNonLocked()) {
//            throw new LockedException("该账号已被锁定!");
//        } else if (!userDetails.isAccountNonExpired()) {
//            throw new AccountExpiredException("该账号已过期!");
//        }
//        return userDetails;
//    }
//
//    /**
//     * openid 认证方式
//     *
//     * @param openId
//     * @return
//     */
//    public UserDetails loadUserByOpenId(String openId) {
//        MemberUserDetails userDetails = null;
//        MemberAuthInfoDTO member = memberUserService.loadUserByOpenId(openId);
//        if (null != member) {
//            userDetails = new MemberUserDetails(member);
//            userDetails.setAuthenticationIdentity(AuthenticationIdentityEnum.OPENID.getValue());   // 认证身份标识:openId
//        }
//        if (userDetails == null) {
//            throw new UsernameNotFoundException(ResultCode.USER_NOT_EXIST.getMsg());
//        } else if (!userDetails.isEnabled()) {
//            throw new DisabledException("该账户已被禁用!");
//        } else if (!userDetails.isAccountNonLocked()) {
//            throw new LockedException("该账号已被锁定!");
//        } else if (!userDetails.isAccountNonExpired()) {
//            throw new AccountExpiredException("该账号已过期!");
//        }
//        return userDetails;
//    }
//}
